import com.proxy.FangDongImpl;
import com.proxy.ZuFang;
import org.junit.Test;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;



public class InvocationDemo {

    @Test
    public void jdk(){

        ZuFang zf = new FangDongImpl();
        InvocationHandler hander = new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("发布房源，网上发布");
                System.out.println("带入上房，介绍并且推销");
                Object invoke = method.invoke("zf","args");
                return invoke;
            }
        };

        ZuFang z = (ZuFang) Proxy.newProxyInstance(InvocationDemo.class.getClassLoader(),
                zf.getClass().getInterfaces(),
                hander
                );

                z.zuFang();
    }


}
